package com.leetcode.partition8;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/1/13 10:46
 */
public class LC747至少是其他数字两倍的最大数 {

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] s = reader.readLine().split("\\s+");
        int[] nums = new int[s.length];
        for (int i = 0; i < s.length; i++) nums[i] = Integer.parseInt(s[i]);
        writer.write(dominantIndex(nums) + "\n");
        writer.flush();
    }

    public static int dominantIndex(int[] nums) {
        if (nums.length == 1) return 0;
        int first = 0, second = -1;
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] >= nums[first]) {
                second = first;
                first = i;
            } else if (second == -1 || nums[i] > nums[second]) second = i;
        }
        return nums[first] >= 2 * nums[second] ? first : -1;
    }
}
